<?php
/**
 * 默认接口服务类
 *
 * @author: dogstar <chanzonghuang@gmail.com> 2014-10-04
 */

class Controller_Index extends Yjnic_Controller {

	private $_index_mod = null;
	

	public function __construct(){
		parent::__construct();
		$this->_index_mod = new Model_Index();
	}

	/**
	 * 主页
	 */
	public function index() {
		$users = $this->_index_mod->getUsers();
		$this->_view->assign('users', $users);
		$user = $this->_index_mod->test2();
		// print_r($user);
		$this->_view->display("index.html");
	}

	/**
	 * 上传测试
	 */
	public function upload(){
		if (empty($_FILES)) {
			$this->_view->display('upload.html');
		}else{
			DI()->upload = new Yjnic_Upload(
				DI()->config->get('app.storage')
			);
			$ret = DI()->upload->upload($_FILES['file']);
			var_dump($ret);
		}		
	}

	//session
	public function session(){
		DI()->session->set('key', array('value'=>1));
		$key = DI()->session->get('key');
		var_dump($key);
	}

	public function cache(){
		DI()->cache->set('key', array('value'=>1));
		$key = DI()->cache->get('key');
		var_dump($key);
	}

	public function verify(){
		$verify = new Yjnic_Verify();
		$verify->entry();
	}

	public function checkVerify(){
		$verify = new Yjnic_Verify();
		$code = DI()->request->get('code');
		$ret = $verify->check($code);
		var_dump($ret);
	}

	public function api(){
		$resource = new Resource_Demo();
		$ret = $resource->getUser();
		print_r($ret);
	}
}